clear
*use "TESS_cleaned_replication.dta"

keep if (christian==1 | prot==1)

preserve
collapse (mean) mean_female = female mean_south = south mean_married = married mean_under30 = under30 mean_over65 = over65 mean_college = college mean_rep = rep mean_cons = cons mean_trump16 = trump16 mean_romney12 = romney12 mean_trump_approve = trump_approve ///
(sd) sd_female = female sd_south = south  sd_married = married sd_under30 = under30 sd_over65 = over65 sd_college = college sd_rep = rep sd_cons = cons sd_trump16 = trump16 sd_romney12 = romney12 sd_trump_approve = trump_approve ///
(count) n_female = female n_south = south n_married = married n_under30 = under30 n_over65 = over65 n_college = college n_rep = rep n_cons = cons n_trump16 = trump16 n_romney12 = romney12 n_trump_approve = trump_approve ///
if ba_only==100 [aw=WEIGHT]
  
foreach j of numlist 1/11{
g test`j'=`j'
}

save "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data1.dta", replace
restore

preserve
collapse (mean) mean_female = female mean_south = south mean_married = married mean_under30 = under30 mean_over65 = over65 mean_college = college mean_rep = rep mean_cons = cons mean_trump16 = trump16 mean_romney12 = romney12 mean_trump_approve = trump_approve ///
(sd) sd_female = female sd_south = south  sd_married = married sd_under30 = under30 sd_over65 = over65 sd_college = college sd_rep = rep sd_cons = cons sd_trump16 = trump16 sd_romney12 = romney12 sd_trump_approve = trump_approve ///
(count) n_female = female n_south = south n_married = married n_under30 = under30 n_over65 = over65 n_college = college n_rep = rep n_cons = cons n_trump16 = trump16 n_romney12 = romney12 n_trump_approve = trump_approve ///
if both==100 [aw=WEIGHT]
  
  foreach i in female south married under30 over65 college rep cons trump16 romney12 trump_approve{
generate hi`i' = mean_`i' + invttail(n_`i'-1,0.08)*(sd_`i' / sqrt(n_`i'))
generate lo`i' = mean_`i' - invttail(n_`i'-1,0.08)*(sd_`i' / sqrt(n_`i'))
}

foreach j of numlist 1 2 3 4 5 6 7 8 9 10 11{
g test`j'=`j'
}

save "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data2.dta", replace
restore

preserve
collapse (mean) mean_female = female mean_south = south mean_married = married mean_under30 = under30 mean_over65 = over65 mean_college = college mean_rep = rep mean_cons = cons mean_trump16 = trump16 mean_romney12 = romney12 mean_trump_approve = trump_approve ///
(sd) sd_female = female sd_south = south  sd_married = married sd_under30 = under30 sd_over65 = over65 sd_college = college sd_rep = rep sd_cons = cons sd_trump16 = trump16 sd_romney12 = romney12 sd_trump_approve = trump_approve ///
(count) n_female = female n_south = south n_married = married n_under30 = under30 n_over65 = over65 n_college = college n_rep = rep n_cons = cons n_trump16 = trump16 n_romney12 = romney12 n_trump_approve = trump_approve ///
if neither==100 [aw=WEIGHT] 
  
foreach i in female south married under30 over65 college rep cons  romney12 trump16 trump_approve{
generate hi`i' = mean_`i' + invttail(n_`i'-1,0.08)*(sd_`i' / sqrt(n_`i'))
generate lo`i' = mean_`i' - invttail(n_`i'-1,0.08)*(sd_`i' / sqrt(n_`i'))
}

foreach j of numlist 1 2 3 4 5 6 7 8 9 10 11{
g test`j'=`j'
}

save "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data3.dta", replace
restore

preserve
collapse (mean) mean_female = female mean_south = south mean_married = married mean_under30 = under30 mean_over65 = over65 mean_college = college mean_rep = rep mean_cons = cons mean_trump16 = trump16 mean_romney12 = romney12 mean_trump_approve = trump_approve ///
(sd) sd_female = female sd_south = south  sd_married = married sd_under30 = under30 sd_over65 = over65 sd_college = college sd_rep = rep sd_cons = cons sd_trump16 = trump16 sd_romney12 = romney12 sd_trump_approve = trump_approve ///
(count) n_female = female n_south = south n_married = married n_under30 = under30 n_over65 = over65 n_college = college n_rep = rep n_cons = cons n_trump16 = trump16 n_romney12 = romney12 n_trump_approve = trump_approve ///
if evan_only==100 [aw=WEIGHT]
   
foreach i in female south married under30 over65 college rep cons  romney12 trump16 trump_approve{
generate hi`i' = mean_`i' + invttail(n_`i'-1,0.08)*(sd_`i' / sqrt(n_`i'))
generate lo`i' = mean_`i' - invttail(n_`i'-1,0.08)*(sd_`i' / sqrt(n_`i'))
}

foreach j of numlist 1 2 3 4 5 6 7 8 9 10 11{
g test`j'=`j'
}

save "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data4.dta", replace
restore

clear
use "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data1.dta"
append using "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data2.dta"
append using "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data3.dta"
append using "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data4.dta"
append using "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data_legend.dta"
cd "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Figures/"

seq type, f(1) t(4)

 tw (scatter test11 mean_female if type==1, col(gs6) msymbol(square) msize(medsmall)) (rcap hifemale lofemale test11 if type==1, hor col (gs6) lpattern(dash) lwidth(med)) /// 
(scatter test11 mean_female if type==2, col(black) msymbol(circle) msize(medsmall)) (rcap hifemale lofemale test11 if type==2, hor col (black) lpattern(dot) lwidth(med)) ///
(scatter test11 mean_female if type==3, col(gs12) msymbol(triangle) msize(medsmall)) (rcap hifemale lofemale test11 if type==3, hor col (gs12) lpattern(solid) lwidth(med)) ///
(scatter test10 mean_south if type==1, col(gs6) msymbol(square) msize(medsmall)) (rcap hisouth losouth test10 if type==1, hor col (gs6) lpattern(dash) lwidth(med)) ///
(scatter test10 mean_south if type==2, col(black) msymbol(circle) msize(medsmall)) (rcap hisouth losouth test10 if type==2, hor col (black) lpattern(dot) lwidth(med)) ///
(scatter test10 mean_south if type==3, col(gs12) msymbol(triangle) msize(medsmall)) (rcap hisouth losouth test10 if type==3, hor col (gs12) lpattern(solid) lwidth(med)) ///
(scatter test9 mean_married if type==1, col(gs6) msymbol(square) msize(medsmall)) (rcap himarried lomarried test9 if type==1, hor col (gs6) lpattern(dash) lwidth(med)) ///
(scatter test9 mean_married if type==2, col(black) msymbol(circle) msize(medsmall)) (rcap  himarried lomarried  test9 if type==2, hor col (black) lpattern(dot) lwidth(med)) ///
(scatter test9 mean_married if type==3, col(gs12) msymbol(triangle) msize(medsmall)) (rcap  himarried lomarried  test9 if type==3, hor col (gs12) lpattern(solid) lwidth(med)) ///
(scatter test8 mean_under30 if type==1, col(gs6) msymbol(square) msize(medsmall)) (rcap hiunder30 lounder30 test8 if type==1, hor col (gs6) lpattern(dash) lwidth(med)) ///
(scatter test8 mean_under30 if type==2, col(black) msymbol(circle) msize(medsmall)) (rcap  hiunder30 lounder30 test8 if type==2, hor col (black) lpattern(dot) lwidth(med)) ///
(scatter test8 mean_under30 if type==3, col(gs12) msymbol(triangle) msize(medsmall)) (rcap  hiunder30 lounder30 test8 if type==3, hor col (gs12) lpattern(solid) lwidth(med)) ///
(scatter test7 mean_over65 if type==1, col(gs6) msymbol(square) msize(medsmall)) (rcap hiover65 loover65 test7 if type==1, hor col (gs6) lpattern(dash) lwidth(med)) ///
(scatter test7 mean_over65 if type==2, col(black) msymbol(circle) msize(medsmall)) (rcap  hiover65 loover65 test7 if type==2, hor col (black) lpattern(dot) lwidth(med)) ///
(scatter test7 mean_over65 if type==3, col(gs12) msymbol(triangle) msize(medsmall)) (rcap  hiover65 loover65 test7 if type==3, hor col (gs12) lpattern(solid) lwidth(med)) ///
(scatter test6 mean_college if type==1, col(gs6) msymbol(square) msize(medsmall)) (rcap hicollege locollege test6 if type==1, hor col (gs6) lpattern(dash) lwidth(med)) ///
(scatter test6 mean_college if type==2, col(black) msymbol(circle) msize(medsmall)) (rcap  hicollege locollege test6  if type==2, hor col (black) lpattern(dot) lwidth(med)) ///
(scatter test6 mean_college if type==3, col(gs12) msymbol(triangle) msize(medsmall)) (rcap  hicollege locollege test6 if type==3, hor col (gs12) lpattern(solid) lwidth(med)) ///
(scatter test5 mean_rep if type==1, col(gs6) msymbol(square) msize(medsmall)) (rcap hirep lorep test5 if type==1, hor col (gs6) lpattern(dash) lwidth(med)) ///
(scatter test5 mean_rep if type==2, col(black) msymbol(circle) msize(medsmall)) (rcap  hirep lorep test5  if type==2, hor col (black) lpattern(dot) lwidth(med)) ///
(scatter test5 mean_rep if type==3, col(gs12) msymbol(triangle) msize(medsmall)) (rcap hirep lorep test5  if type==3, hor col (gs12) lpattern(solid) lwidth(med)) ///
(scatter test4 mean_cons if type==1, col(gs6) msymbol(square) msize(medsmall)) (rcap hicons locons test4 if type==1, hor col (gs6) lpattern(dash) lwidth(med)) ///
(scatter test4 mean_cons if type==2, col(black) msymbol(circle) msize(medsmall)) (rcap  hicons locons test4  if type==2, hor col (black) lpattern(dot) lwidth(med)) ///
(scatter test4 mean_cons if type==3, col(gs12) msymbol(triangle) msize(medsmall)) (rcap hicons locons test4  if type==3, hor col (gs12) lpattern(solid) lwidth(med)) ///
(scatter test2 mean_trump16 if type==1, col(gs6) msymbol(square) msize(medsmall)) (rcap hitrump16 lotrump16 test2 if type==1, hor col (gs6) lpattern(dash) lwidth(med)) ///
(scatter test2 mean_trump16 if type==2, col(black) msymbol(circle) msize(medsmall)) (rcap hitrump16 lotrump16 test2   if type==2, hor col (black) lpattern(dot) lwidth(med)) ///
(scatter test2 mean_trump16 if type==3, col(gs12) msymbol(triangle) msize(medsmall)) (rcap hitrump16 lotrump16 test2   if type==3, hor col (gs12) lpattern(solid) lwidth(med)) ///
(scatter test3 mean_romney12 if type==1, col(gs6) msymbol(square) msize(medsmall)) (rcap hiromney12 loromney12 test3 if type==1, hor col (gs6) lpattern(dash) lwidth(med)) ///
(scatter test3 mean_romney12 if type==2, col(black) msymbol(circle) msize(medsmall)) (rcap hiromney12 loromney12 test3  if type==2, hor col (black) lpattern(dot) lwidth(med)) ///
(scatter test3 mean_romney12 if type==3, col(gs12) msymbol(triangle) msize(medsmall)) (rcap hiromney12 loromney12 test3   if type==3, hor col (gs12) lpattern(solid) lwidth(med)) ///
(scatter test1 mean_trump_approve if type==1, col(gs6) msymbol(square) msize(medsmall)) (rcap hitrump_approve lotrump_approve test1 if type==1, hor col (gs6) lpattern(dash) lwidth(med)) ///
(scatter test1 mean_trump_approve if type==2, col(black) msymbol(circle) msize(medsmall)) (rcap hitrump_approve lotrump_approve test1   if type==2, hor col (black) lpattern(dot) lwidth(med)) ///
(scatter test1 mean_trump_approve if type==3, col(gs12) msymbol(triangle) msize(medsmall)) (rcap hitrump_approve lotrump_approve test1    if type==3, hor col (gs12) lpattern(solid) lwidth(med)) ///
(scatter test0 mean_test if type==1, col(gs6) msymbol(square) msize(medsmall)) (rcap hitest lotest test0 if type==1, hor col (gs6) lpattern(dash) lwidth(med)) ///
(scatter test0 mean_test if type==2, col(black) msymbol(circle) msize(medsmall)) (rcap hitest lotest test0   if type==2, hor col (black) lpattern(dot) lwidth(med)) ///
(scatter test0 mean_test if type==3, col(gs12) msymbol(triangle) msize(medsmall)) (rcap hitest lotest test0    if type==3, hor col (gs12) lpattern(solid) lwidth(med)), ///
ylabel(none) xlabel(none, labsize(medium)) title(" ", size(medium)) legend(off) ///
xscale(range(-.35 1)) yscale(range(-1 11)) ///
xlabel(0(0.2)1, nogrid) scheme(s2color) graphregion(color(white)) ///
ytitle("") ///
text(1 -0.15 "Trump approval", size(medsmall)) ///
text(2 -0.15 "Trump vote '16", size(medsmall)) ///
text(3 -0.15 "Romney vote '12", size(medsmall)) ///
text(4 -0.15 "Conservative", size(medsmall)) ///
text(5 -0.15 "Republican", size(medsmall)) ///
text(6 -0.15 "College degree", size(medsmall)) ///
text(7 -0.15 "Age 65+", size(medsmall)) ///
text(8 -0.15 "Age < 30", size(medsmall)) ///
text(9 -0.15 "Married", size(medsmall)) ///
text(10 -0.15 "Resides in South", size(medsmall)) ///
text(11 -0.15 "Female", size(medsmall)) ///
text(8.5 -.32 "Demographics", size(medsmall) orient(vertical)) ///
text(3 -.32 "Politics", size(medsmall) orient(vertical)) ///
text(0 0.5 "Evan and BA", size(medsmall)) ///
text(0 0.3 "BA only", size(medsmall)) ///
text(0 0.7 "Neither", size(medsmall)) ///
yline(5.5, lcolor(black) lstyle(dot)) 
addplot:  scatteri -0.85 0.2 0.3 0.2 0.3 0.8 -0.85 0.8 -0.85 0.2, recast(area) nodropbase fc(none) lc(black) lwidth(thin) ylabel(none) xlabel(none, labsize(medium)) title("Demographic and political characteristics" "(full sample)", size(medium)) legend(off) ///
xscale(range(-0.35 1)) yscale(range(-1 11)) ///
xlabel(0(0.2)1, nogrid)  graphregion(color(white)) ///
ytitle("") 

		
	
